const {exec,escape} = require('../db/mysql.js');


const loginCheck = (name,pw) => {
	// console.log(name,pw);
	// if(name === "admin" && pw === "123"){
	// 	return true
	// }else {
	// 	return false
	// }
	name = escape(name); //防止sql注入攻击
	pw = escape(pw);
	const sql = `select username, realname from users where username=${name} and password=${pw}`;
	return exec(sql).then(e=>{
		return e[0];
	}); 
};

module.exports = {
	loginCheck
};